/*
 * Logging.cpp
 *
 *  Created on: 19.11.2012
 *      Author: Lapchinskiy
 */
//#include "Global_includes.h"
#include "BuildConfig.h"
#include "Global_types.h"
#include "TimeManager.h"
#include <iostream>
#include <stdio.h>
#include "Logging.h"
using namespace std;
const char *ModuleToStringTable[] = { "Task", "Driver", "UART", "Sensor", "Scheduler","" };

const char *ErrorToStringTable[] = { "No error", "FAILURE", "" };
void Log(char *string) {
#ifdef LOGGING_TO_CONSOLE
	cout<<"-> Time: "<<TimeManager::systemTime<<": ";
	cout <<string<<endl;
#endif
}
void Log(ModuleType module, ErrorCode error, char *string) {

#ifdef LOGGING_TO_CONSOLE
	TimeManager::enabled=FALSE;
	cout<<" -> Time: "<<TimeManager::systemTime<<" ";
	cout<<"Module: "<<ModuleToStringTable[module]<<"	";
	cout <<string<<" ";
	cout<<"Error: "<<ErrorToStringTable[error]<<endl;
	TimeManager::enabled=TRUE;
#endif

}

void Log(LogRecord *logrec, ErrorCode error, char *string) {
#ifdef LOGGING_TO_CONSOLE
	TimeManager::enabled=FALSE;
	cout<<" -> Time: "<<TimeManager::systemTime<<"  ";
	cout<<"Module: "<<ModuleToStringTable[logrec->module]<<"  ";
	cout<<"\""<<logrec->objectName<<"\"  ";
	cout <<""<<string<<"  ";
	cout<<"Error: "<<ErrorToStringTable[error]<<endl;
	TimeManager::enabled=TRUE;
#endif
}


